const { contextBridge, ipcRenderer } = require('electron');

// 暴露安全的API给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  // 获取应用信息
  getAppVersion: () => ipcRenderer.invoke('get-app-version'),
  getAppName: () => ipcRenderer.invoke('get-app-name'),
  
  // 菜单事件监听
  onMenuNewProject: (callback) => {
    ipcRenderer.on('menu-new-project', callback);
  },
  onMenuImportProject: (callback) => {
    ipcRenderer.on('menu-import-project', callback);
  },
  onMenuAbout: (callback) => {
    ipcRenderer.on('menu-about', callback);
  },
  
  // 移除监听器
  removeAllListeners: (channel) => {
    ipcRenderer.removeAllListeners(channel);
  }
});
